<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      label-width="auto"
    >
      <el-form-item label="工单编号" prop="workorderCode">
        <el-input
          v-model="queryParams.workorderCode"
          placeholder="请输入工单编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          v-hasPermi="['mes:qc:earlyWarn:query']"
          >搜索</el-button
        >
      </el-form-item>
    </el-form>
    <el-table
      v-loading="loading"
      :data="qualityList"
      height="calc(100vh - 240px)"
    >
      <el-table-column label="序号" align="center" width="50px">
        <template slot-scope="scope">
          <span>{{ scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="工单编号"
        align="center"
        prop="workorderCode"
      />
      <el-table-column
        label="sn码"
        align="center"
        prop="snCode"
      />
      <el-table-column
        label="预警次数"
        align="center"
        prop="count"
      />

      <el-table-column
        label="产品名称"
        align="center"
        prop="productName"
      />
      <el-table-column
        label="产品编码"
        align="center"
        prop="productCode"
      />
      <el-table-column
        label="产品规格"
        align="center"
        prop="productSpec"
      />
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listAlarm } from "@/api/mes/pro/qualityWarning.js";
export default {
  name: "qualityAnalysis",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        workorderCode: null,
      },
      qualityList: [],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    handleQuery(){
      this.getList()
    },
    /** 查询生产报工记录列表 */
    getList() {
      this.loading = true;
      listAlarm(this.queryParams)
        .then((response) => {
          this.loading = false;
          if (response.rows && response.rows.length) {
            this.qualityList = response.rows;
            this.total = response.total;
          } else {
            this.qualityList = [];
            this.total = 0;
          }
        })
        .catch((err) => {
          this.qualityList = [];
          this.total = 0;
          this.loading = false;
        });
    },
    // 取消按钮
    cancel() {
      this.open = false;
    },
  },
};
</script>
